//
//  WWShopPayController.m
//  Shopping
//
//  Created by 张世敏 on 16/8/23.
//  Copyright © 2016年 张湾湾. All rights reserved.
//

#import "WWShopPayController.h"
#import "WWPayCell.h"

#define kPayCellID @"payCellID"

@interface WWShopPayController() <UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@interface WWShopPayController ()

@end

@implementation WWShopPayController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}


-(void)setupUI{
    [self setupNav];
    self.view.backgroundColor = [UIColor whiteColor];
    self.tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStyleGrouped];
    self.view = self.tableView;
    self.tableView.dataSource = self;
    
    // 注册cell
    [self.tableView registerClass:[WWPayCell class] forCellReuseIdentifier:kPayCellID];
}


/** 设置导航栏 **/
- (void)setupNav{
    self.title = @"结算支付";
    self.navigationController.navigationBar.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem barButtonItemWithImageName:@"v2_goback" target:self action:@selector(didClickBlack)];
}


/** 点击导航栏上返回图标 **/
- (void)didClickBlack{
    // 跳转到上一个页面(待修改)
    [self dismissViewControllerAnimated:YES completion:nil];
}


#pragma mark - tableView dataSource & delegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section == 0) {
        // 第0组(优惠券)
        return 1;
        
    } else if(section == 1) {
        // 第1组(选择支付方式)
        return 5;
        
    } else if(section == 2) {
        // 第2组(精选商品)
        return 3; // 测试数据
        
    } else if(section == 3) {
        // 第3组(费用明细)
        return 1; // 单独抽取一个view
        
    } else {
        return 0;
    }
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    WWPayCell *cell = [tableView dequeueReusableCellWithIdentifier:kPayCellID forIndexPath:indexPath];
    cell.contentView.backgroundColor = KRandomColor;
    cell.textLabel.text = [NSString stringWithFormat:@"%ld,%ld",indexPath.section,indexPath.row];
    
    return cell;
}













@end
